﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IMC.Prepare.Web.Models.Common;
using IMC.Prepare.Core;

namespace IMC.Prepare.Web.Controllers
{
    public class CommonController : Controller
    {
        private readonly IWorkContext _workContext;

        public CommonController(IWorkContext workContext)
        {
            this._workContext = workContext;
        }

        [ChildActionOnly]
        public ActionResult Menu()
        {
            var model = new MenuModel()
            {
                //RecentlyAddedProductsEnabled = _catalogSettings.RecentlyAddedProductsEnabled,
                //BlogEnabled = _blogSettings.Enabled,
                //ForumEnabled = _forumSettings.ForumsEnabled
                RecentlyAddedProductsEnabled = true,
                BlogEnabled = true,
                ForumEnabled = true
            };

            return PartialView(model);
        }

        [ChildActionOnly]
        public ActionResult HeaderLinks()
        {
            //var customer = _workContext.CurrentCustomer;

            //var unreadMessageCount = GetUnreadPrivateMessages();
            //var unreadMessage = string.Empty;
            //var alertMessage = string.Empty;
            //if (unreadMessageCount > 0)
            //{
            //    unreadMessage = string.Format(_localizationService.GetResource("PrivateMessages.TotalUnread"), unreadMessageCount);

            //    //notifications here
            //    if (_forumSettings.ShowAlertForPM &&
            //        !customer.GetAttribute<bool>(SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages))
            //    {
            //        _customerService.SaveCustomerAttribute<bool>(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true);
            //        alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount);
            //    }
            //}
            
            string userUserName = HttpContext.User.Identity.Name;
            var model = new HeaderLinksModel()
            {
                CustomerEmailUsername = HttpContext.User.Identity.Name,
                IsCustomerImpersonated = !string.IsNullOrEmpty(userUserName)
            };

            return PartialView(model);
        }

    }
}
